/*******************************************************************
 * author   :  Charlies-ls
 * Date     :  2021-09-26
 * Function :  vector
 * Copyright (c) 2021. artestplay@outlook.com. All Rights Reserved.
 *******************************************************************/

#ifndef AX_VECTOR_H_
#define AX_VECTOR_H_
#include <stdio.h>
#include <inttypes.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif

typedef struct ax_vector ax_vector;
/* Prototypes. */
ax_vector*  ax_vector_create(size_t item_count, size_t item_size);
void        ax_vector_destory(ax_vector* v);
void        ax_vector_content_destory(ax_vector*v);

size_t      ax_vector_reserve(ax_vector* v, size_t size);
size_t      ax_vector_resize(ax_vector* v,  size_t num);
size_t      ax_vector_size(ax_vector* v);
void*       ax_vector_at(ax_vector* v, size_t index);
size_t      ax_vector_set(ax_vector* v, size_t i, void *val);
size_t      ax_vector_push_back(ax_vector* v, void *val);
void*       ax_vector_erase(ax_vector* v, size_t index);
void        ax_vector_clear(ax_vector* v);




#define ax_vector_foreach(data, vec) \
for(size_t i=0;i<((data = ax_vector_at(vec, i)), ax_vector_size(vec));i++)


#define ax_vector_foreach2(type, data, vec) \
for(size_t i=0;i<((data = (type*)ax_vector_at(vec, i)), ax_vector_size(vec));i++)


#ifdef __cplusplus
}
#endif

#endif
